import Main from '@/views/Main.vue';

// 不作为Main组件的子页面展示的页面单独写，如下
export const loginRouter = {
    path: '/login',
    name: 'login',
    meta: {
        title: 'Login - 登录'
    },
    component: resolve => { require(['@/views/login.vue'], resolve); }
};

export const page404 = {
    path: '/*',
    name: 'error-404',
    meta: {
        title: '404-页面不存在'
    },
    component: resolve => { require(['@/views/error-page/404.vue'], resolve); }
};

export const page403 = {
    path: '/403',
    meta: {
        title: '403-权限不足'
    },
    name: 'error-403',
    component: resolve => { require(['@//views/error-page/403.vue'], resolve); }
};

export const page500 = {
    path: '/500',
    meta: {
        title: '500-服务端错误'
    },
    name: 'error-500',
    component: resolve => { require(['@/views/error-page/500.vue'], resolve); }
};

export const preview = {
    path: '/preview',
    name: 'preview',
    component: resolve => { require(['@/views/form/article-publish/preview.vue'], resolve); }
};

export const locking = {
    path: '/locking',
    name: 'locking',
    component: resolve => { require(['@/views/main-components/lockscreen/components/locking-page.vue'], resolve); }
};

// 作为Main组件的子页面展示但是不在左侧菜单显示的路由写在otherRouter里
export const otherRouter = {
    path: '/',
    name: 'otherRouter',
    redirect: '/home',
    component: Main,
    children: [
        {
            path: 'home',
            title: {i18n: 'home'},
            name: 'home_index',
            component: resolve => { require(['@/views/home/home.vue'], resolve); }
        }, {
            path: 'admin/roleAdd',
            title: '添加角色',
            name: 'roleAdd',
            component: resolve => { require(['@/views/admin/roleAdd.vue'], resolve); }
        }, {
            path: 'admin/add',
            title: '添加管理员',
            name: 'adminAdd',
            component: resolve => { require(['@/views/admin/add.vue'], resolve); }
        }, {
            path: 'user/add',
            title: '添加用户',
            name: 'userAdd',
            component: resolve => { require(['@/views/user/add.vue'], resolve); }
        }, {
            path: 'goods/add',
            title: '添加产品',
            name: 'goodsAdd',
            component: resolve => { require(['@/views/goods/add.vue'], resolve); }
        }, {
            path: 'order/page',
            title: '订单详情',
            name: 'orderPage',
            component: resolve => { require(['@/views/order/page.vue'], resolve); }
        }, {
            path: 'card/page',
            title: '提货卡详情',
            name: 'cardPage',
            component: resolve => { require(['@/views/order/cardPage.vue'], resolve); }
        }, {
            path: 'farmer/add',
            title: '添加农户',
            name: 'farmerAdd',
            component: resolve => { require(['@/views/goods/farmerAdd.vue'], resolve); }
        }, {
            path: 'farm/add',
            title: '添加猪场',
            name: 'farmAdd',
            component: resolve => { require(['@/views/goods/farmAdd.vue'], resolve); }
        }, {
            path: 'pig/add',
            title: '添加土猪',
            name: 'pigAdd',
            component: resolve => { require(['@/views/goods/pigAdd.vue'], resolve); }
        }, {
            path: 'quarantine/add',
            title: '添加土猪检疫',
            name: 'quarantineAdd',
            component: resolve => { require(['@/views/goods/quarantineAdd.vue'], resolve); }
        }, {
            path: 'loopImg/add',
            title: '添加轮播图',
            name: 'loopImgAdd',
            component: resolve => { require(['@/views/website/loopImgAdd.vue'], resolve); }
        }, {
            path: 'webcam/add',
            title: '添加监控',
            name: 'webcamAdd',
            component: resolve => { require(['@/views/website/webcamAdd.vue'], resolve); }
        }, {
            path: 'article/add',
            title: '添加文章',
            name: 'articleAdd',
            component: resolve => { require(['@/views/website/articleAdd.vue'], resolve); }
        }, {
            path: 'comment/add',
            title: '回复评论',
            name: 'commentAdd',
            component: resolve => { require(['@/views/goods/commentAdd.vue'], resolve); }
        }, {
            path: 'shopping',
            title: '购物详情',
            name: 'shopping',
            component: resolve => { require(['@/views/advanced-router/component/shopping-info.vue'], resolve); }
        }, {
            path: 'message',
            title: '消息中心',
            name: 'message_index',
            component: resolve => { require(['@/views/message/message.vue'], resolve); }
        }
    ]
};

// 作为Main组件的子页面展示并且在左侧菜单显示的路由写在appRouter里
export const appRouter = [
    {
        path: '/admin',
        name: 'admin',
        access: 'adminManage',
        title: '系统管理',
        icon: 'ios-contact',
        component: Main,
        children: [
            {
                path: 'menuList',
                name: 'menuList',
                access: 'menuList',
                title: '菜单列表',
                icon: 'android-menu',
                component: resolve => { require(['@/views/admin/menuList.vue'], resolve); }
            }, {
                path: 'permissionList',
                name: 'permissionList',
                access: 'permissionList',
                title: '权限列表',
                icon: 'android-menu',
                component: resolve => { require(['@/views/admin/permissionList.vue'], resolve); }
            }, {
                path: 'roleList',
                name: 'roleList',
                access: 'roleList',
                title: '角色列表',
                icon: 'android-menu',
                component: resolve => { require(['@/views/admin/roleList.vue'], resolve); }
            },
        ]
    },
    {
        path: '/admin',
        name: 'staff',
        access: 'staffManage',
        title: '员工管理',
        icon: 'ios-contact',
        component: Main,
        children: [
            {
                path: 'getList',
                name: 'adminList',
                access: 'adminList',
                title: '员工列表',
                icon: 'android-menu',
                component: resolve => { require(['@/views/admin/getList.vue'], resolve); }
            }, {
                path: 'selfInfo',
                name: 'selfInfo',
                access: 'selfInfo',
                title: '个人中心',
                icon: 'person',
                component: resolve => { require(['@/views/admin/selfInfo.vue'], resolve); }
            }
        ]
    },
    {
        path: '/user',
        name: 'user',
        access: 'user',
        title: '用户管理',
        icon: 'person-stalker',
        component: Main,
        children: [
            {
                path: 'getList',
                name: 'userList',
                access: 'userList',
                title: '用户列表',
                icon: 'android-menu',
                component: resolve => { require(['@/views/user/getList.vue'], resolve); }
            }, {
                path: 'bindList',
                name: 'bindList',
                access: 'bindList',
                title: '绑定列表',
                icon: 'code-working',
                component: resolve => { require(['@/views/user/bindList.vue'], resolve); }
            }, {
                path: 'collectList',
                name: 'collectList',
                access: 'collectList',
                title: '收藏列表',
                icon: 'heart',
                component: resolve => { require(['@/views/user/collectList.vue'], resolve); }
            }, {
                path: 'addList',
                name: 'addList',
                access: 'addList',
                title: '收货地址',
                icon: 'android-pin',
                component: resolve => { require(['@/views/user/addList.vue'], resolve); }
            },
        ]
    },
    {
        path: '/goods',
        name: 'goods',
        title: '产品管理',
        icon: 'ios-cart',
        component: Main,
        children: [
            { path: 'getList', title: '产品列表', name: 'goodsList', icon: 'android-menu', component: resolve => { require(['@/views/goods/getList.vue'], resolve); } },
            { path: 'recycleList', title: '产品回收站', name: 'recycleList', icon: 'ios-trash', component: resolve => { require(['@/views/goods/recycleList.vue'], resolve); } },
            { path: 'commentList', title: '评论列表', name: 'commentList', icon: 'compose', component: resolve => { require(['@/views/goods/commentList.vue'], resolve); } },
            { path: 'farmerList', title: '农户列表', name: 'farmerList', icon: 'ios-person', component: resolve => { require(['@/views/goods/farmerList.vue'], resolve); } },
            { path: 'farmList', title: '猪场列表', name: 'farmList', icon: 'ios-grid-view', component: resolve => { require(['@/views/goods/farmList.vue'], resolve); } },
            { path: 'pmList', title: 'PM2.5列表', name: 'pmList', icon: 'cloud', component: resolve => { require(['@/views/goods/pmList.vue'], resolve); } },
            { path: 'pigList', title: '土猪列表', name: 'pigList', icon: 'bug', component: resolve => { require(['@/views/goods/pigList.vue'], resolve); } },
            { path: 'quarantineList', title: '土猪检疫', name: 'quarantineList', icon: 'bug', component: resolve => { require(['@/views/goods/quarantineList.vue'], resolve); } },
            { path: 'partList', title: '分割列表', name: 'partList', icon: 'pizza', component: resolve => { require(['@/views/goods/partList.vue'], resolve); } },
        ]
    },
    {
        path: '/order',
        name: 'order',
        title: '订单管理',
        icon: 'ios-list',
        component: Main,
        children: [
            { path: 'getList', title: '订单列表', name: 'orderList', icon: 'android-menu', component: resolve => { require(['@/views/order/getList.vue'], resolve); } },
            { path: 'payList', title: '支付列表', name: 'payList', icon: 'cash', component: resolve => { require(['@/views/order/payList.vue'], resolve); } },
            { path: 'preSaleList', title: '预售列表', name: 'preSaleList', icon: 'eye', component: resolve => { require(['@/views/order/preSaleList.vue'], resolve); } },
            { path: 'resellList', title: '转卖列表', name: 'resellList', icon: 'arrow-swap', component: resolve => { require(['@/views/order/resellList.vue'], resolve); } },
            { path: 'cardList', title: '提货卡销售表', name: 'cardList', icon: 'card', component: resolve => { require(['@/views/order/cardList.vue'], resolve); } },
            { path: 'cartList', title: '购物车', name: 'cartList', icon: 'android-cart', component: resolve => { require(['@/views/order/cartList.vue'], resolve); } },
        ]
    },
    {
        path: '/website',
        name: 'website',
        title: '网站管理',
        icon: 'ios-gear',
        component: Main,
        children: [
            { path: 'attacheList', title: '附件列表', name: 'attacheList', icon: 'images', component: resolve => { require(['@/views/website/attacheList.vue'], resolve); } },
            { path: 'downloadList', title: '附件下载列表', name: 'downloadList', icon: 'images', component: resolve => { require(['@/views/website/downloadList.vue'], resolve); } },
            { path: 'tempList', title: '模板列表', name: 'tempList', icon: 'images', component: resolve => { require(['@/views/website/tempList.vue'], resolve); } },
            { path: 'loopList', title: '轮播图', name: 'loopList', icon: 'images', component: resolve => { require(['@/views/website/loopList.vue'], resolve); } },
            { path: 'webcamList', title: '监控列表', name: 'webcamList', icon: 'ios-videocam', component: resolve => { require(['@/views/website/webcamList.vue'], resolve); } },
            { path: 'articleList', title: '文章管理', name: 'articleList', icon: 'ios-book', component: resolve => { require(['@/views/website/articleList.vue'], resolve); } },
            { path: 'tempMsgList', title: '模板消息', name: 'tempMsgList', icon: 'ios-book', component: resolve => { require(['@/views/website/tempMsgList.vue'], resolve); } },
            { path: 'uploadOne', title: '上传图片', name: 'uploadOne', icon: 'upload', component: resolve => { require(['@/views/website/uploadOne.vue'], resolve); } },
        ]
    },
    {
        path: '/loginOut',
        name: 'logout',
        icon: 'log-out',
        title: '退出登录',
        component: Main,
        children: [
            {
                path: '/loginOut',
                name: 'loginOut',
                title: '退出登录',
                icon: 'log-out',
                component: resolve => {require(['@/views/loginOut.vue'], resolve);}
            },
        ]
    },
];

// 所有上面定义的路由都要写在下面的routers里
export const routers = [
    loginRouter,
    otherRouter,
    preview,
    locking,
    ...appRouter,
    page500,
    page403,
    page404
];
